package com.mobiletrain.org.motherkitch.shouye;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.mobiletrain.org.motherkitch.R;
import com.mobiletrain.org.motherkitch.utils.ImageLoad;

import java.util.ArrayList;

/**
 * Created by Administrator on 2015/4/26.
 */
public class StageAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<Stage> data;

    public StageAdapter(Context context, ArrayList<Stage> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        if(data!=null){
            return data.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder1 holder1=null;
        if(convertView==null){
            holder1=new ViewHolder1();
            convertView= LayoutInflater.from(context).inflate(R.layout.shouye_beiyun_item,null);
            holder1.title1= (TextView) convertView.findViewById(R.id.shouye_title1);
            holder1.content1= (TextView) convertView.findViewById(R.id.shouye_content1);
            holder1.image1= (ImageView) convertView.findViewById(R.id.shouye_image1);
            convertView.setTag(holder1);
        }else{
            holder1= (ViewHolder1) convertView.getTag();
        }
        Stage info = data.get(position);
        holder1.title1.setText(info.getTitle());
        holder1.content1.setText(info.getContent());

        BitmapUtils bitmapUtils = ImageLoad.getBitmapUtils(context);
        bitmapUtils.display(holder1.image1, info.getPic());
        return convertView;
    }
    class ViewHolder1{
        TextView title1;
        TextView content1;
        ImageView image1;
    }
}
